﻿using System;
using Skybrud.Social.Json;

namespace Skybrud.Social.Twitter {

    public class TwitterException : Exception {

        public int Code { get; private set; }

        public TwitterException(int code, string message) : base(message) {
            Code = code;
        }

        public static TwitterException Parse(JsonArray array) {
            return Parse(array.GetObject(0));
        }
        
        public static TwitterException Parse(JsonObject obj) {
            return new TwitterException(obj.GetInt("code"), obj.GetString("message"));
        }
    
    }

}
